home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: comp.vuw.ac.nz!HERMES!maths!peterm
- From: peterm@maths.grace.cri.nz (Peter McGavin)
- Subject: Re: AddIntServer + VERTB strangeness
- Message-ID: <PETERM.96Apr8105533@tui.maths.irl.cri.nz>
- Date: 07 Apr 1996 22:55:33 GMT
- References: <199604021335.NAA17260@mailhost.unibol.com>
- <PETERM.96Apr7121414@tui.maths.irl.cri.nz>
- Organization: Industrial Research Ltd
- In-reply-to: peterm@maths.grace.cri.nz's message of 07 Apr 1996 00:14:14 GMT
-
- I wrote:
- >High-level OS calls should internally use the same hardware allocation
- >mechanisms as our own program, so there should be no conflicts. For
- >example, a high-level graphics.library function might call
- >OwnBlitter() and WaitBlit() before it bangs the blitter, just as we
- >could in our own program.
-
- Sorry, I posted in too much haste. John Girvin is right that there is
- a risk of deadlock. For example, our program could directly or
- indirectly call a high-level blitter function, e.g, RectFill() or a
- floppy track decoding function, while we own the blitter between
- OwnBlitter() and DisownBlitter().
-
- However, provided simple rules are followed, deadlocks can happen only
- with hardware allocation functions that block. Fortunately, apart
- from OwnBlitter(), all hardware/resource allocation functions I can
- think of do not block. They immediately return a succeed/fail status
- instead. So only OwnBlitter() is at risk as far as I know.
-
- Anyway, to minimize the risk of deadlock to practically nil:
-
- o Avoid calling OS functions that might use the blitter while the
- blitter is owned. Do not own the blitter for long. Perhaps use
- QBlit() instead (which does not block).
-
- o When a hardware allocation function fails, put up a Retry/Cancel
- requester or equivalent. If the user retries, simply attempt the
- allocation again. If the user cancels, free everything allocated
- so far and either exit the program or wait until the user does
- something to try again.
-
- There is also a risk with LoadView(NULL) for allocating custom gfx.
- That's because LoadView() is not a true allocation function. The risk
- is that another program could call LoadView() while we are banging the
- custom chips. Steps that can be taken to minimise this risk include:
-
- o Install an input-handler before calling LoadView(NULL) and
- remove it after restoring the original View. That prevents
- the user attempting to flip Screens with left-Amiga-M.
-
- o Turn off (most?) system requesters for our process:
- pr = (struct process *)FindTask(NULL);
- oldWindowPtr = pr->pr_WindowPtr;
- pr->pr_WindowPtr = (APTR)-1; /* suppress requesters */
- ...
- pr->pr_WindowPtr = oldWindowPtr;
- See pages 567..568 of The Amiga Guru Book for more details.
-
- o SetFunction() LoadView() to be a no-op function that saves
- its argument in our variable, saved_actiview say. At the
- end, restore the LoadView() function (leaving a stub behind,
- unfortunately) and call LoadView(saved_actiview).
-
- o Inform the user that this program takes over custom gfx and
- warn against simultaneously running other programs that do
- the same.
- --
- Peter McGavin. (p.mcgavin@irl.cri.nz)
-
-